<template>
	<view class="content">
		<view class="title">
			<view class="register">
				<image src="../../../static/logo@2x.png" mode=""></image>
				<input class="phone" maxlength="11" placeholder="手机号码" v-model="mobile" />
				<input class="phone" type="password" maxlength="10" placeholder="登录密码" v-model="password" />
				<view class="code">
					<input class="phone" maxlength="10" placeholder="验证码" v-model="code" />
					<image :src="imags" mode="" @click="switchcode"></image>
				</view>
				<button class="bt1" type="default" @click="login()">登录</button>
				<button class="bt2" type="default" @click="Jump3">注册</button>
				<view class="option">
					<p class="option_tetx1" @click="Jump1">短信验证码登录</p>
					<p class="option_tetx1" @click="Jump2">忘记密码</p>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				title: '登录',
				mobile: "",
				password: "",
				imags: "",
				code: "",
			}
		},
		components: {

		},
		onLoad() {

		},
		onShow() {
			this.verifyCode()
		},
		methods: {
			Jump1() {
				uni.navigateTo({
					url: './message'
				})
			},
			Jump2() {
				uni.navigateTo({
					url: '../modify/index'
				})
			},
			Jump3() {
				uni.navigateTo({
					url: '../register/index'
				})
			},
			login() {
				let data = {
					mobile: this.mobile,
					password: this.password,
					code: this.code
				}
				this.$api.login(data).then(res => {
					this.$common.successToShow(res.data.msg,()=>{})
					if (res.data.msg==="登录成功") {
						this.$db.set('userToken', res.data.data.token)
						this.$common.successToShow(res.data.msg,()=>{
							uni.switchTab({
							    url: '../../index/index'
							});
						})
					}
				}, err => {})
			},
			verifyCode() {
				this.$api.verifyCode({}).then(res => {
					this.imags = res.data.data
				})
			},
			switchcode() {
				this.verifyCode()
			}
		}
	}
</script>
<style lang="less">
	.content {
		background-image: url(../../../static/img-d.png);
		width: 750rpx;
		height: 1334rpx;
		background-size: cover;
		background-repeat: no-repeat;

		.title {
			background-image: url(../../../static/img_t.png);
			background-size: cover;
			background-repeat: no-repeat;
			width: 750rpx;
			height: 478rpx;
			position: relative;

			.register {
				width: 560rpx;
				height: 916rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				position: absolute;
				left: 50%;
				transform: translate(-50%, 20%);
				text-align: center;
				padding: 66rpx 40rpx 0 40rpx;

				image {
					width: 156rpx;
					height: 184rpx;
				}

				.code {
					display: flex;

					image {
						width: 600rpx;
						height: 120rpx;
					}
				}

				.phone {
					text-align: left;
					width: 100%;
					border-bottom: 1px solid #D2D2D2;
					margin-top: 40rpx;
					font-size: 24rpx;
					color: #C1C1C1;
					height: 80rpx;
				}

				.bt1 {
					margin-top: 40rpx;
					height: 78rpx;
					background: linear-gradient(77deg, #4E7BFA 0%, #764CFA 100%);
					font-size: 28rpx;
					color: #FFFFFF;
					line-height: 78rpx;
				}

				.bt2 {
					margin-top: 40rpx;
					height: 78rpx;
					border: 1px solid #764CFA;
					opacity: 1;
					border-radius: 4px;
					color: #764CFA;
					font-size: 28rpx;
				}

				.option {
					margin-top: 20rpx;
					display: flex;
					justify-content: space-between;
					height: 30rpx;

					.option_tetx1 {
						color: #764CFA;
						font-size: 20rpx;
					}
				}
			}
		}
	}
</style>
